<?php 
define('_VIEW_MODEL_','default');
include("./init.php");
//$result = $db->GetRow('select * from no_admin');
//$userId = getUserId();
$friend = "";
$word  = 'time';
$tisor   = 'asc';
$resor   = 'desc';
$sort    = 'asc';
$friend="";
$bid   = array();
require_once INC.'/pageclass.php';
//$pageObj = new Page(34,10,$smartyObj);
$id = isset($id)?intval($id):"";
if(isset($vid)&&!empty($vid)){
	$vid = intval($vid);
}else{
	$vid = $id;
}
if(isset($act)&&$act=="order"){
	$word = $key;
	if($word == 'time'){
		$sort =  $tisort; 
		$tisor  = $tisort;
		
	}else{
		$sort =  $resort;
		$resor  = $resort;
	}
}
$rs = $db->Execute("select * from {$telper}bbs_cont where userid = '$id'");
//echo "select * from {$telper}bbs_cont where userid = '$id'";
$bbs = $rs->GetArray();
if(!empty($bbs)){
	foreach($bbs as $k=>$v){
		$bid[] = $v['id'];
		$mybbs[$v['id']] = $v;
	}	
}else{
	$mybbs = "false";
}
if(!empty($bbs)){
	$bid = implode(",",$bid);
	$rn = $db->Execute("select count(id),bbsid {$telper}bbs_reply where  bbsid in ($bid)");
	if(!empty($rn)){
		$num = $rn->GetArray();
		foreach ($num as $k=>$v){
			$num[$v['bbsid']] = $v['count(id)'];
		}
	}else{
		$num = "false";
	}
}else{
	$num = false;
}
$info = orderarray($mybbs,$num,$word,$sort);
$rf = $db->Execute("select `title`,`link` from {$telper}friendlink where state = 0 order by rank desc");
$friendinfo = $rf ->GetArray();
foreach($friendinfo as $k=>$v){
	$friend .="<a href='$v[link]'>$v[title]</a>";
	$k = $k+1;
	if($k%4 ==0 && count($friend)%4 != 0){
		$friend .="<br/>";
	}
	if($k%4 !=0 && count($friendinfo)>$k){
		$friend .=".";
	}
}
//print_R($info);
$num = $db->GetRow("select count(id) from {$telper}bbs_cont where column2 = '$bid'");
$info = $rs->GetArray();
require_once INC.'/pageclass.php';
new Page($num['count(id)'],$pageSize,$smartyObj);

header("Content-type:text/vnd.wap.wml;charset=utf-8");
$smartyObj->assign('friendlink',$friend);
$smartyObj->assign('info',$info);
$smartyObj->assign("uid",$id);
$smartyObj->assign("vid",$vid);
$smartyObj->assign("tistat",$tisor);
$smartyObj->assign("restat",$resor);
$smartyObj->display("mybbs.tpl");

?>